<extend name="common/common" />

<block name="title"><title>仟途旅游</title></block>

<block name='css'>

</block>

<block name="content">
    <div id="content">
        <div class="section-preview" id="content1" style="padding: 0em 0px">
            <div class="container">
                <h2>路线</h2><br>
                <div class="row" id="row1" value = {$search['title']}>

                </div>
                <div class="container" align="center" style="display: block;">
                    <ul class="pagination" id="pagination1" >
                        <!-- Pages-->
                    </ul>
                </div>
            </div>

        </div>

        <div class="section-preview" id="content2" style="padding: 0em 0px">
            <div class="container">
                <h2 style="margin-top: -35px">攻略</h2><br>
                <div class="row" id="row">

                </div>
            </div>
            <div class="container" align="center" style="display: block;">
                <ul class="pagination" id="pagination">
                    <!-- Pages-->
                </ul>
            </div>

        </div>
    </div>


    <input id="search" type="text" style="display: none" value={$search['title']} >
    <div id="temp" style="display: none">
        <div  class="col-lg-3 col-sm-4" >
            <div class="preview" style="min-height: 329px ">
                <div class="image">
                    <a href="#" rel="nofollow" >
                        <img style="width: 360px;height: 166px" src="" class="img-responsive" alt="">
                    </a>
                </div>
                <div class="options" style="padding: 0em 2em 0em">
                    <h3></h3>
                    <p style="margin-bottom: 1em"></p>
                    <div class="btn-group">
                        <a href="#" class="btn btn-info">查看详情</a>
                    </div>
                </div>
            </div>
        </div>

    </div>
</block>

<block name="js">
    <script>
        fixFooter();

        var fetchData1 = function(furl){
            if(furl==null){
                url1 = "{:U('Search/getRouteList')}"
            }else{
                url1 = furl;
            }
            $.ajax({
                url:url1,
                type:'GET',
                dataType:'json',
                data:{
                    'search':$('#search').val()
                }, success:function(json){
                    if(json.state!='1'){
                        alert("出错了");
                        return;
                    }

                    var show = json.show;
                    if(show == "" || show.total == 0){
                        $('#row1').html('<p align="center">没有找到你要的路线哦!!</p>');
                        $('#pagination1').html("");
                        return;
                    }else{
                        //列表渲染
                        var list = json.data;
                        var $template_list_tbody = $('#temp');
                        var template_render = '';
                        for(var i in list){
                            $('#temp img').attr('src','__PUBLIC__/uploads/routeImage/'+list[i].img_url);
                            $('#temp h3').html(list[i].name);
                            $('#temp p').text(list[i].company);
                            $('#temp a').attr('href','{:U(\'Route/readRoute\')}?id='+list[i].id);
                            template_render += $template_list_tbody.html();
                        }
                        $('#row1').html(template_render);


                    }
                    make_page1(json.show,'#pagination1','?');
                    $('html,body').animate({'scrollTop':0},300);
                    if(show.total<4)
                        $('#pagination1').html("");
                }
            })
        }

        var fetchData = function(furl){
            if(furl==null){
                url = "{:U('Search/getStrategyList')}"
            }else{
                url = furl;
            }
            $.ajax({
                url:url,
                type:'GET',
                dataType:'json',
                data:{
                    'search':$('#search').val()
                }, success:function(json){
                    if(json.state!='1'){
                        alert("出错了");
                        return;
                    }

                    var show = json.show;
                    if(show == "" || show.total == 0){
                        $('#row').html('<p align="center">没有找到你要的攻略哦!!</p>');
                        $('#pagination').html("");
                        return;
                    }else{
                        //列表渲染
                        var list = json.data;
                        var $template_list_tbody = $('#temp');
                        var template_render = '';
                        for(var i in list){
                            $('#temp img').attr('src','__PUBLIC__/uploads/strategyImage/'+list[i].img_url);
                            $('#temp h3').html(list[i].name);
                            $('#temp p').text(list[i].company);
                            $('#temp a').attr('href','{:U(\'Strategy/readStrategy\')}?id='+list[i].id);
                            template_render += $template_list_tbody.html();
                        }
                        $('#row').html(template_render);

                    }
                    make_page(json.show,'#pagination','?');
                    if(show.total<4)
                        $('#pagination').html("");
                }
            })
        }

        fetchData1();
        fetchData();

        $('.st').removeClass('active1');
        $('.ou').removeClass('active1');
        $('.ro').removeClass('active1');
        $('.hp').removeClass('active1');
        $('#search_input').attr('value',$('#search').val());
        $('html,body').animate({'scrollTop':0},300);
    </script>
</block>

